package com.wms.goods_stock_view.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wms.common.annotation.Log;
import com.wms.common.core.controller.BaseController;
import com.wms.common.core.domain.AjaxResult;
import com.wms.common.enums.BusinessType;
import com.wms.goods_stock_view.domain.GoodsStockView;
import com.wms.goods_stock_view.service.IGoodsStockViewService;
import com.wms.common.utils.poi.ExcelUtil;
import com.wms.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author 熊竹俊
 * @date 2025-01-16
 */
@RestController
@RequestMapping("/goods_stock_view/goods_stock_view")
public class GoodsStockViewController extends BaseController
{
    @Autowired
    private IGoodsStockViewService goodsStockViewService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('goods_stock_view:goods_stock_view:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsStockView goodsStockView)
    {
        startPage();
        List<GoodsStockView> list = goodsStockViewService.selectGoodsStockViewList(goodsStockView);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('goods_stock_view:goods_stock_view:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsStockView goodsStockView)
    {
        List<GoodsStockView> list = goodsStockViewService.selectGoodsStockViewList(goodsStockView);
        ExcelUtil<GoodsStockView> util = new ExcelUtil<GoodsStockView>(GoodsStockView.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('goods_stock_view:goods_stock_view:query')")
    @GetMapping(value = "/{goodsId}")
    public AjaxResult getInfo(@PathVariable("goodsId") Long goodsId)
    {
        return success(goodsStockViewService.selectGoodsStockViewByGoodsId(goodsId));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('goods_stock_view:goods_stock_view:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodsStockView goodsStockView)
    {
        return toAjax(goodsStockViewService.insertGoodsStockView(goodsStockView));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('goods_stock_view:goods_stock_view:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodsStockView goodsStockView)
    {
        return toAjax(goodsStockViewService.updateGoodsStockView(goodsStockView));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('goods_stock_view:goods_stock_view:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodsIds}")
    public AjaxResult remove(@PathVariable Long[] goodsIds)
    {
        return toAjax(goodsStockViewService.deleteGoodsStockViewByGoodsIds(goodsIds));
    }
}
